package com.xxx.mapper;

import com.xxx.pojo.Package;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PackageMapper {

    @Select("select * from package limit #{index},#{num};")
    @ResultMap("packageResultMap")
    List<Package> selectAll(@Param("index") int index,@Param("num") int num);

    @Select("select * from package where code = #{code} ;")
    @ResultMap("packageResultMap")
    Package selectByCode(Long code);

    @Delete("delete from package where code = #{code};")
    int delByCode(Long code);


    @Update("update package set types_name = #{typesName},name = #{name},price = #{price},state = #{state},tip = #{describe},img=#{img},update_time=#{updateTime},update_user=#{updateUser}  where code=#{code};")
    int updatePackage(Package p);

    @Insert("insert into package values (#{typesName},#{name},#{price},#{state},#{code},#{describe},#{img},#{createTime},#{updateTime},#{createUser},#{updateUser},#{dele})")
    int addPackage(Package aPackage);

    @Select("select count(*) from package;")
    int getCount();

    @Select("select * from package where name = #{name};")
    @ResultMap("packageResultMap")
    Package selectByName(@Param("name") String name);
}
